import { EntityModel } from '@midwayjs/orm';
import {
  Column,
  PrimaryGeneratedColumn,
  // ManyToMany,
  // JoinTable
  // OneToMany,
  ManyToOne,
  // JoinTable,
  // OneToOne,
  JoinColumn,
} from 'typeorm';
import dayjs from 'dayjs';
import { UserEntity } from './user';

@EntityModel({
  name: 'friend',
})
export class FriendEntity {
  @PrimaryGeneratedColumn({
    type: 'bigint',
    comment: '主键id',
  })
  id: number;

  @Column({
    type: 'int',
    name: 'uid',
    nullable: false, // 不能为null
    comment: '用户id',
  })
  userId: number;

  @Column({
    type: 'int',
    name: 'friend_id',
    nullable: false, // 不能为null
    comment: '好友id',
  })
  friendId: number;

  @Column({
    type: 'varchar',
    name: 'create_time',
    length: 20,
    nullable: false, // 不能为null
    default: dayjs().format('YYYY-MM-DD HH:mm:ss'), // 默认值
    comment: '创建时间',
  })
  createTime: string;

  // @ManyToOne(type => UserEntity, user => user.friends)
  @ManyToOne(type => UserEntity)
  @JoinColumn({
    name: 'friend_id',
  })
  users: UserEntity;
}
